const path = require("path");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const {VueLoaderPlugin} = require("vue-loader");//在vue-loader版本15及以后都是作为插件引入
module.exports = {
    entry:path.join(__dirname,"./src/app.js"),
    output:{
        path:path.join(__dirname,"./dist"),
        filename:"main.js"
    },
    plugins: [
        new HtmlWebpackPlugin({
            template:path.join(__dirname,"./src/index.html"),
            filename:"index.html"
        }),
        new VueLoaderPlugin()
    ],
    module: {
        rules: [
            {test:/\.css$/,use:["style-loader","css-loader"]},
            {test:/\.less$/,use:["style-loader","css-loader","less-loader"]},//依赖 less
            {test:/\.scss$/,use:["style-loader","css-loader","sass-loader"]},//依赖 node-sass
            {test:/\.(png|gif|bmp|png|jpef|bmp|jpg)$/,use:"url-loader?limit=200&name=[hash:8]-[name].[ext]"},//依赖内部模块 file-loader
            {test:/\.(ttf|woff|woff2|eot|svg)$/,use:"url-loader"},//处理字体库
            {test:/\.js$/,use:"babel-loader",exclude:/node_modules/},//处理js文件
            {test:/\.vue$/, use: "vue-loader"}//处理vue文件 依赖于 vue-template-compiler
        ]
    }
};